/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import model.Login;
import view.frameHOMEPAGE;
//import view.frameLOGIN;
import java.sql.Connection;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import view.FrameDaftarObatAdmin;

/**
 *
 * @author Dell
 */
public class Login_kontrol {
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */

    private Connection conn;

    public Login_kontrol(Connection koneksi) {
        this.conn = koneksi;
    }

    public static Login_kontrol getKoneksiLogin() throws SQLException {
        Login_kontrol log = new Login_kontrol(OraConnection.getKoneksi());
        return log;
    }

    public void cekLogin(Login login) {
        // Login_kontrol lk = new Login_kontrol(conn);
        Login log = new Login();
        String user = login.getUser();
        String pass = login.getPsw();
        if (user.equals("admin") && pass.equals("admin")) {
            JOptionPane.showMessageDialog(null, "Selamat Datang \nAnda berhasil Login!");
//
//            view.FrameDaftarObatAdmin  fdoa = new FrameDaftarObatAdmin();
//            fdoa.setVisible(true);
//            //fdoa.setResizable(false);
//            frameLOGIN fl = new frameLOGIN();
//            fl.setVisible(false);
//            fl.setResizable(false);
//            fl.dispose();
//            frameHOMEPAGE fhp = new frameHOMEPAGE();
//            //fhp.setVisible(false);
//            fhp.dispose();
        } else {
            JOptionPane.showMessageDialog(null, "Usename atau password salah \nUlangi lagi!");
//            frameLOGIN fl = new frameLOGIN();
//            fl.setVisible(false);
//            fl.setResizable(false);
        }
    }
}
